package main

import (
	"fmt"
	"time"
)

func g1(ch chan struct{}) {
	time.Sleep(100 * time.Millisecond)
	ch <- struct{}{}
}
func g2(ch chan struct{}) {
	ch <- struct{}{}
}

func m() {

	c1 := make(chan struct{})
	c2 := make(chan struct{})
	go g1(c1)
	go g2(c2)
	timer := time.NewTimer(time.Millisecond * 50)
	for {
		select {
		case <-c1:
			fmt.Println("c1 done")
		case <-c2:
			fmt.Println("c2 done")
		case <-timer.C:
			fmt.Println("timeout")
			return
		}
	}

}
